package edu.cmu.javadb;

import java.util.*;
import java.lang.reflect.*;

public class IndexInfo {
	
	private String indexName;

	private List<Attribute> attributes = new ArrayList<Attribute>();
	
	public boolean isCompatible(List<Attribute> fields) {
		//TODO this algorithm is just a super naive algorithm, ensure the they contain same set of fields
		if (attributes.size() != fields.size())
			return false;
		for (int i = 0; i < attributes.size(); i++) {
			if (!attributes.get(i).equals(fields.get(i))) {
				return false;
			}
		}
		return true;
	}
	
	public void addAttribute(Attribute att) {
		attributes.add(att);
	}
	
	public List<Attribute> getAttributes() {
		return attributes;
	}

	public String getIndexName() {
		return indexName;
	}
	
	//TODO use map for efficiency
	public boolean containAttribute(Attribute att) {
		return attributes.contains(att);
	}
}
